#!/bin/bash

awk -F: 'BEGIN {
    printf "List of Users\n"
    printf "---------------------------------------------------------\n"
    #这里使用%-20s保持对齐
    printf "%-20s %-20s %-20s\n", "UserName", "GroupId", "Shell Path"
    printf "---------------------------------------------------------\n"
}
{    printf "%-20s %-20s %-20s\n", $1, $4, $7
     shellCount[$7]++
}
END {
    printf "---------------------------------------------------------\n"
    for (shell in shellCount) {
        printf "%s have %d times.\n", shell, shellCount[shell]
    }
}' /etc/passwd > awk1.out

